
var index
function request(url,data="",type="get"){
    return new Promise(function(resolve,reject){
        $.ajax({
            url,
            type,
            data,
            dataType:"json",
            timeout:"60000",
            beforeSend(){
                index  = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            },
            success(res){
                console.log(res);
                resolve(res)
            },
            error(err){
                reject(err);
            },
            complete(){
                console.log("complete")
                setTimeout(()=>{
                    layer.close(index);
                },1000);
            }
        })
    })
}


// 登录
const login_ajax =  params=> request("../php/login_account.php",params,"post");

const register_ajax =  params=> request("../php/register.php",params,"post");

const  isUser_ajax = params =>request("../php/isExistUser.php",params,"get");
const  isPhone_ajax = params =>request("../php/isExistPhone.php",params,"get");
const  isEmail_ajax = params =>request("../php/isExistEmail.php",params,"get");
const  getGoodList_ajax = params =>request("../php/searchGoodList.php",params,"get");

const getGoodOneDetail = params=>request("../php/getGoodOneDetail.php",params,"get");

const addToShopcart = params=>request("../php/addToShopcart.php",params,"get");

const getCartList = params=>request("../php/getCartList.php",params,"post");

const deleteOneById = params=>request("../php/deleteOneById.php",params,"get");
